// Copyright Leonid Shlyapnikov 2010
// Distributed under the GNU Lesser General Public License http://www.gnu.org/licenses/lgpl.html
//    author: Leonid Shlyapnikov, created on: Jan 30, 2010

#ifndef FIXPARSER_CPP_SRC_MAIN_FIXPARSER_RAWDATA_H_
#define FIXPARSER_CPP_SRC_MAIN_FIXPARSER_RAWDATA_H_

#include <boost/utility.hpp>
#include <vector>
#include <string>

#include "./Base.h"
#include "./MemoryArea.h"


namespace fixparser {

class RawData: public Base {
public:
    static const int DEFAULT_CAPACITY;

    explicit RawData(MemoryArea* const memoryArea);
    explicit RawData(const int initial_capacity, MemoryArea* const memoryArea);
    virtual ~RawData();

    void data(const char* data, int length);
    void data(const std::string& data);
    const char* data() const;
    void ensure_capacity(int capacity);

    template<typename T> void writeTo(T output) const;

private:
    MemoryArea *const memoryArea_;
    int capacity_;
    int size_;
    char* data_;
};

}

#endif  // FIXPARSER_CPP_SRC_MAIN_FIXPARSER_RAWDATA_H_
